<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="/interceptor.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@page isELIgnored="false" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>休假信息列表</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	function del(id){
		if(confirm("确定操作？")){
			window.location.href = "vacationdelete?id="+id;
		}
	}
	function show(next,total){
		if (next<=0) {
			alert("已经是首页了");
			return;
		}
		if (next>total) {
			alert("已经是尾页了");
			return;
		}
		document.forms[0].action="vacationselectNextPage?page="+next;
		document.forms[0].submit();
	}
</script>
</head>

<body onload="setit()">
	<div class="action">
		<div class="t">
			休假信息列表
		</div>
		<div class="pages">
			<table width="90%" border="1" cellpadding="0" cellspacing="0" style="border:thin solid #666; margin-top:20px">
            	<tr>
                	<th width="11%">申&nbsp;请&nbsp;人</th>
                    <th width="14%">开始时间</th>
                    <th width="14%">结束时间</th>
                    <th width="6%">天数</th>
                    <th width="10%">审核状态</th>
                    <th width="16%">请假原因</th>
                    <th width="11%">审&nbsp;核&nbsp;人</th>
                    <th width="14%">操作</th>
                </tr>
         <c:if test="${list!= null}">
            <c:forEach var="v" items="${list}">
            	<input type="hidden" id="id" name="id" value=""/>
				<tr>
				
                    <td align="center">${v.name}</td>
                    <td align="center">
                    	<fmt:formatDate value="${v.startTime}" pattern="yyyy-MM-dd"/>
                    </td>
                    <td align="center">
                    <fmt:formatDate value="${v.endTime}" pattern="yyyy-MM-dd"/>
                    </td>
                    <td align="center">${v.days}</td>
                    <td align="center">
                    	<c:if test="${v.state==0}">未审核</c:if>
                    	<c:if test="${v.state==1}">审核通过</c:if>
                    	<c:if test="${v.state==2}">审核拒绝</c:if>
                    </td>
                    <td align="center">${v.reason}</td>
                    <td align="center">${v.checker}</td>
                   		<td align="center">
                        <c:if test="${user.role=='经理' && v.state==0 && v.name != user.userName}">
                    		[<a href="vacationfindById?id=${v.id }" style="color:red">审核</a>]
                        </c:if>
                        <c:if test="${user.role=='经理' && v.state!=0}">
                    		<font color="gray">已审核</font>
                        </c:if>
                        <c:if test="${user.role=='经理' && v.state==0 && v.name == user.userName}">[<a href="javascript:del(${v.id })" style="color:red">取消申请</a>]</c:if>
                        <c:if test="${user.role=='经理' && v.state!=0 && v.name == user.userName}">[<a href="javascript:del(${v.id })" style="color:red">删除</a>]</c:if>
                  
                        <c:if test="${user.role=='普通员工' && v.state==0}">
                    		[<a href="javascript:del(${v.id })" style="color:red">取消申请</a>]
                        </c:if>
                        <c:if test="${user.role=='普通员工' && v.state!=0}">
                    		[<a href="javascript:del(${v.id })" style="color:red">删除</a>]
                        </c:if>
                    	</td>
				</tr>
            </c:forEach>
         </c:if>
            
            </table>
     <div> 
  		 第${currentPage }页
		<input type="hidden" id="tpage" name="tpage"
		 value="${totalPage} "></input>
		<c:if test="${currentPage>1 }">
		<input type="button" value="首页" onclick="show(1)"></input>
		<input type="button" value="上一页" onclick="show(${currentPage-1})"></input>
		</c:if>
		<c:if test="${currentPage<totalPage }">
		<input type="button" value="下一页" onclick="show(${currentPage+1},${totalPage })"></input>
		<input type="button" value="尾页" onclick="show(${totalPage})"></input>
		</c:if>
		共${totalPage }页  
	</div>
	<br/>
	<br/>
         <form id="addForm" name="addForm" action="vacationfindManage" method="post">
		 	<input type="submit" id="add" value="申请休假" />
         </form>
		</div>
	</div>
</body>
</html>